***********************************************************************************
* Merging National Employment Matrix with OEWS and O*NET data 
* last modified 12/3/2022
*
* Note: Clean and merge OEWS, NEM, ONET data
*
***********************************************************************************

clear
capture log close 
set more off

***************
* Directories *
***************

cd "/Users/"

global dofile			=	"./Code/NEW-OEWS"
global matrix_data		=   "./Data/National Employment Matrix"
global oews_data		= 	"./Data/OEWS/all_excel"
global onet_data		= 	"./OccLink/ONET/ONET data/merged"
global xwalk 			=	"./OOH 2000-2020 markup/Mturk/FinalCrosswalk"
global results 			=	"./Results"
global temp				= 	"./Temp"


set scheme plotplainblind, permanently

*******************************************************************************
** Clean O*NET Education, Training, and Experience data (2003-)
*******************************************************************************

/*------------------------------*/
/*1. Required Education         */
/*------------------------------*/
{
import excel "${onet_data}/edu_training_exp.xlsx", sheet("EDU_TRAINING_EXP") firstrow case(lower) clear

** reorder variables
order o_net_soc_code title element_id element_name scale_id category ///
	 _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11


** keep education entries 
keep if element_name == "Required Level of Education"

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** combine different waves from the same year
forvalues x = 2003/2022 {
	egen edu_dist`x' = rowmedian(_`x'_*)
	}


** create a numeric category variable
destring category, replace


** replace category with the approximated years of education
recode category (1 = 9 "less than a high school diploma") ///
				(2 = 12 "high school diploma-or the equivalent (GED)") ///
				(3 = 12 "post-secondary certificate") ///
				(4 = 13 "some college courses") ///
				(5 = 14 "associate's degree (or other 2-year degree)") ///
				(6 = 16 "bachelor's degree") ///
				(7 = 16 "post-baccalaureate certificate") ///
				(8 = 17 "master's degree") ///
				(9 = 17 "post-master certificate") ///
				(10 = 20 "first professional degree includes at least 2yrs of college work and at least 6 academic years of work to complete") ///
				(11 = 21 "doctoral degree") ///
				(12 = 21 "post-doctoral training"), gen(edu_level)

				
** generate average years of education for each onet occupation 
forvalues i = 2003(1)2022 {
		bys o_net_soc_code: gen temp_onet_edu`i' = edu_level * edu_dist`i'/100
		bys o_net_soc_code: egen avg_onet_edu`i' = total(temp_onet_edu`i'), missing
		drop temp_onet_edu`i'
}

** keep one copy for each onet occupation 
bys o_net_soc_code: keep if _n == 1

** generate average years of education for each soc occupation (aggregating onet occ) 
forvalues i = 2003(1)2022 {
		bys soc: egen avg_edu`i' = mean(avg_onet_edu`i')
}

** keep one copy for each soc occupation 
bys soc: keep if _n == 1

** keep useful variables
keep soc avg_edu2003-avg_edu2022

** reshape into a long soc*year file
reshape long avg_edu, i(soc) j(year) 

** add label
label var avg_edu "Average Required Level Of Education 1-12 (O*Net)"


save "${temp}/onet_edu03-22combined.dta", replace
}

/*-----------------------------------*/
/*2. Related Work Experience         */
/*-----------------------------------*/

{
import excel "${onet_data}/edu_training_exp.xlsx", sheet("EDU_TRAINING_EXP") firstrow case(lower) clear

** reorder variables
order o_net_soc_code title element_id element_name scale_id category ///
	 _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11

	 
** keep work experience entries 
keep if element_name == "Related Work Experience"

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** combine different waves from the same year
forvalues x = 2003/2022 {
	egen exp_dist`x' = rowmedian(_`x'_*)
	}

** create a numeric category variable
destring category, replace

** replace category with the approximated years of work experince

/* category labels.                 */
/* 1 "none"                         */
/* 2 "up to 1 month"                */
/* 3 "over 1 month up to 3 months"  */
/* 4 "over 3 months up to 6 months" */
/* 5 "over 6 months up to 1 year"   */
/* 6 "over 1 year up to 2 years"    */
/* 7 "over 2 years up to 4 years"   */
/* 8 "over 4 years up to 6 years"   */
/* 9 "over 6 years up to 8 years"   */
/* 10 "over 8 years up to 10 years" */
/* 11 "over 10 years"               */

recode category (1 = 0)    ///
				(2 = 0.1)  ///
				(3 = 0.25) ///
				(4 = 0.5)  ///
				(5 = 0.5)  ///
				(6 = 1.5)  ///
				(7 = 3)    ///
				(8 = 5)    ///
				(9 = 7)    ///
				(10 = 9)   ///
				(11 = 10), gen(exp_level)

** generate average years of work experience for each onet occupation 
forvalues i = 2003(1)2022 {
		bys o_net_soc_code: gen temp_onet_exp`i' = exp_level * exp_dist`i'/100
		bys o_net_soc_code: egen avg_onet_exp`i' = total(temp_onet_exp`i'), missing
		drop temp_onet_exp`i'
}

** keep one copy for each onet occupation 
bys o_net_soc_code: keep if _n == 1

** generate average years of work experience for each soc occupation (aggregating onet occ) 
forvalues i = 2003(1)2022 {
		bys soc: egen avg_exp`i' = mean(avg_onet_exp`i')
}

** keep one copy for each soc occupation 
bys soc: keep if _n == 1

** keep useful variables
keep soc avg_exp2003-avg_exp2022

** reshape into a long soc*year file
reshape long avg_exp, i(soc) j(year) 

** add label
label var avg_exp "Average Related Work Experience (1-11) (O*Net)"


save "${temp}/onet_exp03-22combined.dta", replace
}

/*----------------------------------------*/
/*3. On-Site or In-Plant Training         */
/*----------------------------------------*/
{
import excel "${onet_data}/edu_training_exp.xlsx", sheet("EDU_TRAINING_EXP") firstrow case(lower) clear

** reorder variables
order o_net_soc_code title element_id element_name scale_id category ///
	 _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11

	 
** keep on-site or in-plant training entries 
keep if element_name == "On-Site or In-Plant Training"

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** combine different waves from the same year
forvalues x = 2003/2022 {
	egen onsite_train_dist`x' = rowmedian(_`x'_*)
	}

** create a numeric category variable
destring category, replace

** replace category with the approximated years of on-site training

/* category labels.                 */
/* 1 "none"                         */
/* 2 "up to 1 month"                */
/* 3 "over 1 month up to 3 months"  */
/* 4 "over 3 months up to 6 months" */
/* 5 "over 6 months up to 1 year)"  */
/* 6 "over 1 year up to 2 years")   */
/* 7 "over 2 years up to 4 years")  */
/* 8 "over 4 years up to 10 years"  */
/* 9 "over 10 years"                */

				
recode category (1 = 0)    ///
				(2 = 0.1)  ///
				(3 = 0.25) ///
				(4 = 0.5)  ///
				(5 = 0.5)  ///
				(6 = 1.5)  ///
				(7 = 3)    ///
				(8 = 7)    ///
				(9 = 10), gen(onsite_train_level)

** generate average years of on-site training for each onet occupation 
forvalues i = 2003(1)2022 {
		bys o_net_soc_code: gen temp_onet_onsite_train`i' = onsite_train_level * onsite_train_dist`i'/100
		bys o_net_soc_code: egen avg_onet_onsite_train`i' = total(temp_onet_onsite_train`i'), missing
		drop temp_onet_onsite_train`i'
}

** keep one copy for each onet occupation 
bys o_net_soc_code: keep if _n == 1

** generate average years of work experience for each soc occupation (aggregating onet occ) 
forvalues i = 2003(1)2022 {
		bys soc: egen avg_onsite_train`i' = mean(avg_onet_onsite_train`i')
}

** keep one copy for each occupation 
bys soc: keep if _n == 1

** keep useful variables
keep soc avg_onsite_train2003-avg_onsite_train2022

** reshape into a long soc*year file
reshape long avg_onsite_train, i(soc) j(year) 

** add label
label var avg_onsite_train "Average On-Site or In-Plant Training (1-9) (O*Net)"


save "${temp}/onet_onsite_train03-22combined.dta", replace
}

/*-------------------------------*/
/*4. On-the-Job Training         */
/*-------------------------------*/
{
import excel "${onet_data}/edu_training_exp.xlsx", sheet("EDU_TRAINING_EXP") firstrow case(lower) clear

** reorder variables
order o_net_soc_code title element_id element_name scale_id category ///
	 _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11

	 
** keep on-the-job training entries  
keep if element_name == "On-the-Job Training"

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** combine different waves from the same year
forvalues x = 2003/2022 {
	egen job_train_dist`x' = rowmedian(_`x'_*)
	}

** create a numeric category variable
destring category, replace

** replace category with the approximated years of job training

/* category labels.                 */
/* 1 "none"                         */
/* 2 "up to 1 month"                */
/* 3 "over 1 month up to 3 months"  */
/* 4 "over 3 months up to 6 months" */
/* 5 "over 6 months up to 1 year"   */
/* 6 "over 1 year up to 2 years"    */
/* 7 "over 2 years up to 4 years"   */
/* 8 "over 4 years up to 10 years"  */
/* 9 "over 10 years"                */

				
recode category (1 = 0)    ///
				(2 = 0.1)  ///
				(3 = 0.25) ///
				(4 = 0.5)  ///
				(5 = 0.5)  ///
				(6 = 1.5)  ///
				(7 = 3)    ///
				(8 = 7)    ///
				(9 = 10), gen(job_train_level)

** generate average years of job training for each onet occupation 
forvalues i = 2003(1)2022 {
		bys o_net_soc_code: gen temp_onet_job_train`i' = job_train_level * job_train_dist`i'/100
		bys o_net_soc_code: egen avg_onet_job_train`i' = total(temp_onet_job_train`i'), missing
		drop temp_onet_job_train`i'
}

** keep one copy for each onet occupation 
bys o_net_soc_code: keep if _n == 1

** generate average years of job training for each soc occupation (aggregating onet occ) 
forvalues i = 2003(1)2022 {
		bys soc: egen avg_job_train`i' = mean(avg_onet_job_train`i')
}

** keep one copy for each soc occupation 
bys soc: keep if _n == 1

** keep useful variables
keep soc avg_job_train2003-avg_job_train2022

** reshape into a long soc*year file
reshape long avg_job_train, i(soc) j(year) 

** add label
label var avg_job_train "Average On-the-Job Training (1-9) (O*Net)"


save "${temp}/onet_job_train03-22combined.dta", replace
}

/*--------------------------*/
/*5. Apprenticeship         */
/*--------------------------*/
{
import excel "${onet_data}/edu_training_exp.xlsx", sheet("EDU_TRAINING_EXP") firstrow case(lower) clear

** reorder variables
order o_net_soc_code title element_id element_name scale_id category ///
	 _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11

** keep apprenticeship entries  
keep if element_name == "Apprenticeship"

** generate soc code
gen soc = substr(o_net_soc_code,1,7)


** combine different waves from the same year
forvalues x = 2003/2022 {
	egen apprentice`x' = rowmedian(_`x'_*)
}

** generate the importance of apprenticeship for each soc occupation 
forvalues i = 2003(1)2022 {
		bys soc: egen avg_apprentice`i' = mean(apprentice`i')
}

** keep one copy for each soc occupation 
bys soc: keep if _n == 1

** keep useful variables
keep soc avg_apprentice2003-avg_apprentice2022

** reshape into a long soc*year file
reshape long avg_apprentice, i(soc) j(year) 

** add label
label var avg_apprentice "Importance of Apprenticeship 0-5 (O*Net)"


save "${temp}/onet_apprentice03-22combined.dta", replace
}

/*--------------------------------------------------*/
/*6. Job-Related Professional Certification         */
/*--------------------------------------------------*/
{
import excel "${onet_data}/edu_training_exp.xlsx", sheet("EDU_TRAINING_EXP") firstrow case(lower) clear

** reorder variables
order o_net_soc_code title element_id element_name scale_id category ///
	 _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11

** keep job-related professional certification entries  	 
keep if element_name == "Job-Related Professional Certification"

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** combine different waves from the same year
forvalues x = 2003/2022 {
	egen certification`x' = rowmedian(_`x'_*)
}

** generate the importance of certification for each soc occupation 
forvalues i = 2003(1)2022 {
		bys soc: egen avg_cert`i' = mean(certification`i')
}

** keep one copy for each soc occupation 
bys soc: keep if _n == 1

** keep useful variables
keep soc avg_cert2003-avg_cert2022

** reshape into a long soc*year file
reshape long avg_cert, i(soc) j(year) 

** add label
label var avg_cert "Importance of Job-Related Professional Certification 0-5 (O*Net)"


save "${temp}/onet_cert03-22combined.dta", replace
}

*******************************************************************************
** Clean O*NET Task Rating data (2008-)
*******************************************************************************
{
import excel "${onet_data}/task_ratings.xlsx", sheet("TASK_RATINGS") firstrow case(lower) clear

** reorder variables
order o_net_soc_code title scale_name scale_id category ///
	 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11


** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** encode element_name to a numeric variable
gen element = scale_name + " " + category
encode element, gen(taskratingname)

** combine different waves from the same year
foreach x of numlist 2008/2022 {
	
		egen onet_taskrating`x' = rowmedian(_`x'_*)
	}

** generate the task rating variables for each soc occupation 
foreach x of numlist 2008(1)2022 {
		bys soc taskratingname: egen taskrating_`x' = mean(onet_taskrating`x')
}

** keep one copy for each soc occupation's skill 
bys soc taskratingname: keep if _n == 1

** keep useful variables
keep soc taskratingname taskrating_2008-taskrating_2022

** reshape into a long soc*year*skill file
egen newid = concat(soc taskratingname), punct(-tk)
reshape long taskrating_, i(newid) j(year) 

** reshape into a wide soc*year file
drop newid
egen newid = concat(soc year), punct(-yr)
reshape wide taskrating_, i(newid) j(taskratingname) 
drop newid

** rename variables
rename taskrating_1 task_freq_1
rename taskrating_2 task_freq_2
rename taskrating_3 task_freq_3
rename taskrating_4 task_freq_4
rename taskrating_5 task_freq_5
rename taskrating_6 task_freq_6
rename taskrating_7 task_freq_7
rename taskrating_8 task_importance
rename taskrating_9 task_relevance


** add labels to skill variables  
	 
/* category labels.                            */
/* 1	Yearly or less                         */
/* 2	More than yearly                       */
/* 3	More than monthly                      */
/* 4	More than weekly                       */
/* 5	Daily                                  */
/* 6	Several times daily                    */
/* 7	Hourly or more                         */

lab var task_freq_1         "Frequency of Task (Categories 1-7) 1-Yearly or less" 
lab var task_freq_2         "Frequency of Task (Categories 1-7) 2-More than yearly" 
lab var task_freq_3         "Frequency of Task (Categories 1-7) 3-More than monthly"
lab var task_freq_4         "Frequency of Task (Categories 1-7) 4-More than weekly"
lab var task_freq_5         "Frequency of Task (Categories 1-7) 5-Daily"
lab var task_freq_6         "Frequency of Task (Categories 1-7) 6-Several times daily"
lab var task_freq_7         "Frequency of Task (Categories 1-7) 7-Hourly or more"
lab var task_importance     "Importance"
lab var task_relevance      "Relevance of Task"

save "${temp}/onet_taskrating08-22combined.dta", replace
}


*******************************************************************************
** Clean O*NET Work Context data (2000-)
*******************************************************************************
{
import excel "${onet_data}/work_context.xlsx", sheet("WORK_CONTEXT") firstrow case(lower) clear

** reorder variables
order o_net_soc_code title element_id element_name scale_id category  ///
	 _2000_8  _2001_6  _2002_7  _2003_4  _2003_11 _2004_7  _2004_12  ///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11


** generate soc code
gen soc = substr(o_net_soc_code,1,7)


** keep average score of CX and CT
** CX frequency scales vary across elements, e.g., 
** 1	Never
** 2	Once a year or more but not every month
** 3	Once a month or more but not every week
** 4	Once a week or more but not every day
** 5	Every day
** note: some variable may vary from 1 to 3 not 1 to 5

keep if inlist(scale_id, "CX", "CT") & inlist(category, "0")

** encode element_name to a numeric variable
gen element = element_name 
encode element, gen(wkcontextname)

** combine different waves from the same year
foreach x of numlist 2000/2022 {
	
		egen onet_wkcontext`x' = rowmedian(_`x'_*)
	}

** generate the task rating variables for each soc occupation 
foreach x of numlist 2000(1)2022 {
		bys soc wkcontextname: egen wkcontext_`x' = mean(onet_wkcontext`x')
}

** keep one copy for each soc occupation's skill 
bys soc wkcontextname: keep if _n == 1

** keep useful variables
keep soc wkcontextname wkcontext_2000-wkcontext_2022

** reshape into a long soc*year*skill file
egen newid = concat(soc wkcontextname), punct(-tk)
reshape long wkcontext_, i(newid) j(year) 

** reshape into a wide soc*year file
drop newid
egen newid = concat(soc year), punct(-yr)
reshape wide wkcontext_, i(newid) j(wkcontextname) 
drop newid


lab	var	wkcontext_1		"Consequence of Error"
lab	var	wkcontext_2		"Contact With Others"
lab	var	wkcontext_3		"Coordinate or Lead Others"
lab	var	wkcontext_4		"Cramped Work Space, Awkward Positions"
lab	var	wkcontext_5		"Deal With External Customers"
lab	var	wkcontext_6		"Deal With Physically Aggressive People"
lab	var	wkcontext_7		"Deal With Unpleasant or Angry People"
lab	var	wkcontext_8		"Degree of Automation"
lab	var	wkcontext_9		"Duration of Typical Work Week"
lab	var	wkcontext_10	"Electronic Mail"
lab	var	wkcontext_11	"Exposed to Contaminants"
lab	var	wkcontext_12	"Exposed to Disease or Infections"
lab	var	wkcontext_13	"Exposed to Hazardous Conditions"
lab	var	wkcontext_14	"Exposed to Hazardous Equipment"
lab	var	wkcontext_15	"Exposed to High Places"
lab	var	wkcontext_16	"Exposed to Minor Burns, Cuts, Bites, or Stings"
lab	var	wkcontext_17	"Exposed to Radiation"
lab	var	wkcontext_18	"Exposed to Whole Body Vibration"
lab	var	wkcontext_19	"Extremely Bright or Inadequate Lighting"
lab	var	wkcontext_20	"Face-to-Face Discussions"
lab	var	wkcontext_21	"Freedom to Make Decisions"
lab	var	wkcontext_22	"Frequency of Conflict Situations"
lab	var	wkcontext_23	"Frequency of Decision Making"
lab	var	wkcontext_24	"Impact of Decisions on Co-workers or Company Results"
lab	var	wkcontext_25	"Importance of Being Exact or Accurate"
lab	var	wkcontext_26	"Importance of Repeating Same Tasks"
lab	var	wkcontext_27	"In an Enclosed Vehicle or Equipment"
lab	var	wkcontext_28	"In an Open Vehicle or Equipment"
lab	var	wkcontext_29	"Indoors, Environmentally Controlled"
lab	var	wkcontext_30	"Indoors, Not Environmentally Controlled"
lab	var	wkcontext_31	"Letters and Memos"
lab	var	wkcontext_32	"Level of Competition"
lab	var	wkcontext_33	"Outdoors, Exposed to Weather"
lab	var	wkcontext_34	"Outdoors, Under Cover"
lab	var	wkcontext_35	"Pace Determined by Speed of Equipment"
lab	var	wkcontext_36	"Physical Proximity"
lab	var	wkcontext_37	"Public Speaking"
lab	var	wkcontext_38	"Responsibility for Outcomes and Results"
lab	var	wkcontext_39	"Responsible for Others' Health and Safety"
lab	var	wkcontext_40	"Sounds, Noise Levels Are Distracting or Uncomfortable"
lab	var	wkcontext_41	"Spend Time Bending or Twisting the Body"
lab	var	wkcontext_42	"Spend Time Climbing Ladders, Scaffolds, or Poles"
lab	var	wkcontext_43	"Spend Time Keeping or Regaining Balance"
lab	var	wkcontext_44	"Spend Time Kneeling, Crouching, Stooping, or Crawling"
lab	var	wkcontext_45	"Spend Time Making Repetitive Motions"
lab	var	wkcontext_46	"Spend Time Sitting"
lab	var	wkcontext_47	"Spend Time Standing"
lab	var	wkcontext_48	"Spend Time Using Your Hands to Handle, Control, or Feel Objects, Tools, or Controls"
lab	var	wkcontext_49	"Spend Time Walking and Running"
lab	var	wkcontext_50	"Structured versus Unstructured Work"
lab	var	wkcontext_51	"Telephone"
lab	var	wkcontext_52	"Time Pressure"
lab	var	wkcontext_53	"Very Hot or Cold Temperatures"
lab	var	wkcontext_54	"Wear Common Protective or Safety Equipment"
lab	var	wkcontext_55	"Wear Specialized Protective or Safety Equipment"
lab	var	wkcontext_56	"Work Schedules"
lab	var	wkcontext_57	"Work With Work Group or Team"
					
save "${temp}/onet_wkcontext00-22combined.dta", replace					
		
}


*******************************************************************************
** Clean O*NET Skill data
*******************************************************************************
{
import excel "${onet_data}/skills.xlsx", sheet("SKILLS") firstrow case(lower) clear

** reorder variables
order o_net_soc_code-scale_id ///
	 _2000_8  _2001_6  _2002_7  _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** encode element_name to a numeric variable
gen element = element_name + " " + element_id + " " + scale_id
encode element, gen(skillname)


** combine different waves from the same year
foreach x of numlist 2000/2022 {
	
		egen onet_skill`x' = rowmedian(_`x'_*)
	}

** generate the skill variables for each soc occupation 
foreach x of numlist 2000(1)2022 {
		bys soc skillname: egen skill_`x' = mean(onet_skill`x')
}

** keep one copy for each soc occupation's skill 
bys soc skillname: keep if _n == 1

** keep useful variables
keep soc skillname skill_2000-skill_2022 

** reshape into a long soc*year*skill file
egen newid = concat(soc skillname), punct(-sk)
reshape long skill_, i(newid) j(year) 

** reshape into a wide soc*year file
drop newid
egen newid = concat(soc year), punct(-yr)
reshape wide skill_, i(newid) j(skillname) 
drop newid

** add labels to skill variables  
lab var skill_1                 "Active Learning 2.A.2.b IM" 
lab var skill_2                 "Active Learning 2.A.2.b LV" 
lab var skill_3                "Active Listening 2.A.1.b IM"
lab var skill_4                "Active Listening 2.A.1.b LV"
lab var skill_5         "Complex Problem Solving 2.B.2.i IM"
lab var skill_6         "Complex Problem Solving 2.B.2.i LV"
lab var skill_7                    "Coordination 2.B.1.b IM"
lab var skill_8                    "Coordination 2.B.1.b LV"
lab var skill_9               "Critical Thinking 2.A.2.a IM"
lab var skill_10              "Critical Thinking 2.A.2.a LV"
lab var skill_11          "Equipment Maintenance 2.B.3.j IM"
lab var skill_12          "Equipment Maintenance 2.B.3.j LV"
lab var skill_13            "Equipment Selection 2.B.3.c IM"
lab var skill_14            "Equipment Selection 2.B.3.c LV"
lab var skill_15                "Idea Evaluation 2.B.2.f IM"
lab var skill_16                "Idea Evaluation 2.B.2.f LV"
lab var skill_17                "Idea Generation 2.B.2.e IM"
lab var skill_18                "Idea Generation 2.B.2.e LV"
lab var skill_19   "Identification of Key Causes 2.B.4.d IM"
lab var skill_20   "Identification of Key Causes 2.B.4.d LV"
lab var skill_21   "Identifying Downstream Consequences 2.B.4.c IM"
lab var skill_22   "Identifying Downstream Consequences 2.B.4.c LV"
lab var skill_23        "Implementation Planning 2.B.2.g IM"
lab var skill_24        "Implementation Planning 2.B.2.g LV"
lab var skill_25          "Information Gathering 2.B.2.b IM"
lab var skill_26          "Information Gathering 2.B.2.b LV"
lab var skill_27       "Information Organization 2.B.2.c IM"
lab var skill_28       "Information Organization 2.B.2.c LV"
lab var skill_29                   "Installation 2.B.3.d IM"
lab var skill_30                   "Installation 2.B.3.d LV"
lab var skill_31                    "Instructing 2.B.1.e IM"
lab var skill_32                    "Instructing 2.B.1.e LV"
lab var skill_33   "Judgment and Decision Making 2.B.4.e IM"
lab var skill_34   "Judgment and Decision Making 2.B.4.e LV"
lab var skill_35            "Learning Strategies 2.A.2.c IM"
lab var skill_36            "Learning Strategies 2.A.2.c LV"
lab var skill_37   "Management of Financial Resources 2.B.5.b IM"
lab var skill_38   "Management of Financial Resources 2.B.5.b LV"
lab var skill_39   "Management of Material Resources 2.B.5.c IM"
lab var skill_40   "Management of Material Resources 2.B.5.c LV"
lab var skill_41   "Management of Personnel Resources 2.B.5.d IM"
lab var skill_42   "Management of Personnel Resources 2.B.5.d LV"
lab var skill_43                    "Mathematics 2.A.1.e IM"
lab var skill_44                    "Mathematics 2.A.1.e LV"
lab var skill_45                     "Monitoring 2.A.2.d IM"
lab var skill_46                     "Monitoring 2.A.2.d LV"
lab var skill_47                    "Negotiation 2.B.1.d IM"
lab var skill_48                    "Negotiation 2.B.1.d LV"
lab var skill_49           "Operation Monitoring 2.B.3.g IM"
lab var skill_50           "Operation Monitoring 2.B.3.g LV"
lab var skill_51          "Operation and Control 2.B.3.h IM"
lab var skill_52          "Operation and Control 2.B.3.h LV"
lab var skill_53            "Operations Analysis 2.B.3.a IM"
lab var skill_54            "Operations Analysis 2.B.3.a LV"
lab var skill_55                     "Persuasion 2.B.1.c IM"
lab var skill_56                     "Persuasion 2.B.1.c LV"
lab var skill_57         "Problem Identification 2.B.2.a IM"
lab var skill_58         "Problem Identification 2.B.2.a LV"
lab var skill_59             "Product Inspection 2.B.3.i IM"
lab var skill_60             "Product Inspection 2.B.3.i LV"
lab var skill_61                    "Programming 2.B.3.e IM"
lab var skill_62                    "Programming 2.B.3.e LV"
lab var skill_63       "Quality Control Analysis 2.B.3.m IM"
lab var skill_64       "Quality Control Analysis 2.B.3.m LV"
lab var skill_65          "Reading Comprehension 2.A.1.a IM"
lab var skill_66          "Reading Comprehension 2.A.1.a LV"
lab var skill_67                      "Repairing 2.B.3.l IM"
lab var skill_68                      "Repairing 2.B.3.l LV"
lab var skill_69                        "Science 2.A.1.f IM"
lab var skill_70                        "Science 2.A.1.f LV"
lab var skill_71            "Service Orientation 2.B.1.f IM"
lab var skill_72            "Service Orientation 2.B.1.f LV"
lab var skill_73          "Social Perceptiveness 2.B.1.a IM"
lab var skill_74          "Social Perceptiveness 2.B.1.a LV"
lab var skill_75             "Solution Appraisal 2.B.2.h IM"
lab var skill_76             "Solution Appraisal 2.B.2.h LV"
lab var skill_77                       "Speaking 2.A.1.d IM"
lab var skill_78                       "Speaking 2.A.1.d LV"
lab var skill_79       "Synthesis/Reorganization 2.B.2.d IM"
lab var skill_80       "Synthesis/Reorganization 2.B.2.d LV"
lab var skill_81               "Systems Analysis 2.B.4.g IM"
lab var skill_82               "Systems Analysis 2.B.4.g LV"
lab var skill_83             "Systems Evaluation 2.B.4.f IM"
lab var skill_84             "Systems Evaluation 2.B.4.f LV"
lab var skill_85             "Systems Evaluation 2.B.4.h IM"
lab var skill_86             "Systems Evaluation 2.B.4.h LV"
lab var skill_87             "Systems Perception 2.B.4.b IM"
lab var skill_88             "Systems Perception 2.B.4.b LV"
lab var skill_89              "Technology Design 2.B.3.b IM"
lab var skill_90              "Technology Design 2.B.3.b LV"
lab var skill_91                        "Testing 2.B.3.f IM"
lab var skill_92                        "Testing 2.B.3.f LV"
lab var skill_93                "Time Management 2.B.5.a IM"
lab var skill_94                "Time Management 2.B.5.a LV"
lab var skill_95                "Troubleshooting 2.B.3.k IM"
lab var skill_96                "Troubleshooting 2.B.3.k LV"
lab var skill_97                      "Visioning 2.B.4.a IM"
lab var skill_98                      "Visioning 2.B.4.a LV"
lab var skill_99                        "Writing 2.A.1.c IM"
lab var skill_100                       "Writing 2.A.1.c LV"

save "${temp}/onet_skill00-22combined.dta", replace
}	
	
*******************************************************************************
** Clean O*NET Ability data (2000-)
*******************************************************************************
{
import excel "${onet_data}/abilities.xlsx", sheet("ABILITIES") firstrow case(lower) clear

** reorder variables
order o_net_soc_code-scale_id  ///
	 _2000_8  _2001_6  _2002_7  _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11
	 

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** encode element_name to a numeric variable
gen element = element_name + " " + element_id + " " + scale_id
encode element, gen(abilityname)


** combine different waves from the same year
foreach x of numlist 2000/2022 {
	
		egen onet_ability`x' = rowmedian(_`x'_*)
	}

** generate the ability variables for each soc occupation 
foreach x of numlist 2000(1)2022 {
		bys soc abilityname: egen ability_`x' = mean(onet_ability`x')
}

** keep one copy for each soc occupation's ability
bys soc abilityname: keep if _n == 1

** keep useful variables
keep soc abilityname ability_2000-ability_2022

** reshape into a long soc*year*ability file
egen newid = concat(soc abilityname), punct(-ab)
reshape long ability_, i(newid) j(year) 

** reshape into a wide soc*year file
drop newid
egen newid = concat(soc year), punct(-yr)
reshape wide ability_, i(newid) j(abilityname) 
drop newid


** add labels to ability variables
lab var ability_1   "Arm-Hand Steadiness 1.A.2.a.1 IM"
lab var ability_2   "Arm-Hand Steadiness 1.A.2.a.1 LV"
lab var ability_3  	"Auditory Attention 1.A.4.b.2 IM"
lab var ability_4  	"Auditory Attention 1.A.4.b.2 LV"
lab var ability_5  	"Category Flexibility 1.A.1.b.7 IM"
lab var ability_6  	"Category Flexibility 1.A.1.b.7 LV"
lab var ability_7  	"Control Precision 1.A.2.b.1 IM"
lab var ability_8  	"Control Precision 1.A.2.b.1 LV"
lab var ability_9  	"Deductive Reasoning 1.A.1.b.4 IM"
lab var ability_10 	"Deductive Reasoning 1.A.1.b.4 LV"
lab var ability_11 	"Depth Perception 1.A.4.a.6 IM"
lab var ability_12 	"Depth Perception 1.A.4.a.6 LV"
lab var ability_13 	"Dynamic Flexibility 1.A.3.c.2 IM"
lab var ability_14 	"Dynamic Flexibility 1.A.3.c.2 LV"
lab var ability_15 	"Dynamic Strength 1.A.3.a.3 IM"
lab var ability_16 	"Dynamic Strength 1.A.3.a.3 LV"
lab var ability_17 	"Explosive Strength 1.A.3.a.2 IM"
lab var ability_18 	"Explosive Strength 1.A.3.a.2 LV"
lab var ability_19 	"Extent Flexibility 1.A.3.c.1 IM"
lab var ability_20 	"Extent Flexibility 1.A.3.c.1 LV"
lab var ability_21 	"Far Vision 1.A.4.a.2 IM"
lab var ability_22 	"Far Vision 1.A.4.a.2 LV"
lab var ability_23 	"Finger Dexterity 1.A.2.a.3 IM"
lab var ability_24 	"Finger Dexterity 1.A.2.a.3 LV"
lab var ability_25 	"Flexibility of Closure 1.A.1.e.2 IM"
lab var ability_26 	"Flexibility of Closure 1.A.1.e.2 LV"
lab var ability_27 	"Fluency of Ideas 1.A.1.b.1 IM"
lab var ability_28 	"Fluency of Ideas 1.A.1.b.1 LV"
lab var ability_29 	"Glare Sensitivity 1.A.4.a.7 IM"
lab var ability_30 	"Glare Sensitivity 1.A.4.a.7 LV"
lab var ability_31 	"Gross Body Coordination 1.A.3.c.3 IM"
lab var ability_32 	"Gross Body Coordination 1.A.3.c.3 LV"
lab var ability_33 	"Gross Body Equilibrium 1.A.3.c.4 IM"
lab var ability_34 	"Gross Body Equilibrium 1.A.3.c.4 LV"
lab var ability_35 	"Hearing Sensitivity 1.A.4.b.1 IM"
lab var ability_36 	"Hearing Sensitivity 1.A.4.b.1 LV"
lab var ability_37 	"Inductive Reasoning 1.A.1.b.5 IM"
lab var ability_38 	"Inductive Reasoning 1.A.1.b.5 LV"
lab var ability_39 	"Information Ordering 1.A.1.b.6 IM"
lab var ability_40 	"Information Ordering 1.A.1.b.6 LV"
lab var ability_41 	"Manual Dexterity 1.A.2.a.2 IM"
lab var ability_42 	"Manual Dexterity 1.A.2.a.2 LV"
lab var ability_43 	"Mathematical Reasoning 1.A.1.c.1 IM"
lab var ability_44 	"Mathematical Reasoning 1.A.1.c.1 LV"
lab var ability_45 	"Memorization 1.A.1.d.1 IM"
lab var ability_46 	"Memorization 1.A.1.d.1 LV"
lab var ability_47 	"Multilimb Coordination 1.A.2.b.2 IM"
lab var ability_48 	"Multilimb Coordination 1.A.2.b.2 LV"
lab var ability_49 	"Near Vision 1.A.4.a.1 IM"
lab var ability_50 	"Near Vision 1.A.4.a.1 LV"
lab var ability_51 	"Night Vision 1.A.4.a.4 IM"
lab var ability_52 	"Night Vision 1.A.4.a.4 LV"
lab var ability_53 	"Number Facility 1.A.1.c.2 IM"
lab var ability_54 	"Number Facility 1.A.1.c.2 LV"
lab var ability_55 	"Oral Comprehension 1.A.1.a.1 IM"
lab var ability_56 	"Oral Comprehension 1.A.1.a.1 LV"
lab var ability_57 	"Oral Expression 1.A.1.a.3 IM"
lab var ability_58 	"Oral Expression 1.A.1.a.3 LV"
lab var ability_59 	"Originality 1.A.1.b.2 IM"
lab var ability_60 	"Originality 1.A.1.b.2 LV"
lab var ability_61 	"Perceptual Speed 1.A.1.e.3 IM"
lab var ability_62 	"Perceptual Speed 1.A.1.e.3 LV"
lab var ability_63 	"Peripheral Vision 1.A.4.a.5 IM"
lab var ability_64 	"Peripheral Vision 1.A.4.a.5 LV"
lab var ability_65 	"Problem Sensitivity 1.A.1.b.3 IM"
lab var ability_66 	"Problem Sensitivity 1.A.1.b.3 LV"
lab var ability_67 	"Rate Control 1.A.2.b.4 IM"
lab var ability_68 	"Rate Control 1.A.2.b.4 LV"
lab var ability_69 	"Reaction Time 1.A.2.c.1 IM"
lab var ability_70 	"Reaction Time 1.A.2.c.1 LV"
lab var ability_71 	"Response Orientation 1.A.2.b.3 IM"
lab var ability_72 	"Response Orientation 1.A.2.b.3 LV"
lab var ability_73 	"Selective Attention 1.A.1.g.1 IM"
lab var ability_74 	"Selective Attention 1.A.1.g.1 LV"
lab var ability_75 	"Sound Localization 1.A.4.b.3 IM"
lab var ability_76 	"Sound Localization 1.A.4.b.3 LV"
lab var ability_77 	"Spatial Orientation 1.A.1.f.1 IM"
lab var ability_78 	"Spatial Orientation 1.A.1.f.1 LV"
lab var ability_79 	"Speech Clarity 1.A.4.b.5 IM"
lab var ability_80 	"Speech Clarity 1.A.4.b.5 LV"
lab var ability_81 	"Speech Recognition 1.A.4.b.4 IM"
lab var ability_82 	"Speech Recognition 1.A.4.b.4 LV"
lab var ability_83 	"Speed of Closure 1.A.1.e.1 IM"
lab var ability_84 	"Speed of Closure 1.A.1.e.1 LV"
lab var ability_85 	"Speed of Limb Movement 1.A.2.c.3 IM"
lab var ability_86 	"Speed of Limb Movement 1.A.2.c.3 LV"
lab var ability_87 	"Stamina 1.A.3.b.1 IM"
lab var ability_88 	"Stamina 1.A.3.b.1 LV"
lab var ability_89 	"Static Strength 1.A.3.a.1 IM"
lab var ability_90 	"Static Strength 1.A.3.a.1 LV"
lab var ability_91 	"Time Sharing 1.A.1.g.2 IM"
lab var ability_92 	"Time Sharing 1.A.1.g.2 LV"
lab var ability_93 	"Trunk Strength 1.A.3.a.4 IM"
lab var ability_94 	"Trunk Strength 1.A.3.a.4 LV"
lab var ability_95 	"Visual Color Discrimination 1.A.4.a.3 IM"
lab var ability_96 	"Visual Color Discrimination 1.A.4.a.3 LV"
lab var ability_97 	"Visualization 1.A.1.f.2 IM"
lab var ability_98 	"Visualization 1.A.1.f.2 LV"
lab var ability_99 	"Wrist-Finger Speed 1.A.2.c.2 IM"
lab var ability_100	"Wrist-Finger Speed 1.A.2.c.2 LV"
lab var ability_101	"Written Comprehension 1.A.1.a.2 IM"
lab var ability_102	"Written Comprehension 1.A.1.a.2 LV"
lab var ability_103	"Written Expression 1.A.1.a.4 IM"
lab var ability_104	"Written Expression 1.A.1.a.4 LV"

save "${temp}/onet_ability00-22combined.dta", replace
}


*******************************************************************************
** Clean O*NET Interest data (2000-)
*******************************************************************************
{
import excel "${onet_data}/interests.xlsx", sheet("INTERESTS") firstrow case(lower) clear

** reorder variables
order o_net_soc_code-scale_id ///
	 _2000_8  _2001_6  _2002_7  _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11 

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** encode element_name to a numeric variable
gen element = element_name + " " + element_id + " " + scale_id
encode element, gen(interestname)


** combine different waves from the same year
foreach x of numlist 2000/2022 {
	
		egen onet_interest`x' = rowmedian(_`x'_*)
	}

** generate the interest variables for each soc occupation 
foreach x of numlist 2000(1)2022 {
		bys soc interestname: egen interest_`x' = mean(onet_interest`x')
}

** keep one copy for each soc occupation's interest
bys soc interestname: keep if _n == 1

** keep useful variables
keep soc interestname interest_2000-interest_2022 

** reshape into a long soc*year*interest file
egen newid = concat(soc interestname), punct(-int)
reshape long interest_, i(newid) j(year) 

** reshape into a wide soc*year file
drop newid
egen newid = concat(soc year), punct(-yr)
reshape wide interest_, i(newid) j(interestname) 
drop newid

** add labels to interest variables
lab var interest_1 "Artistic 1.B.1.c OI"
lab var interest_2 "Conventional 1.B.1.f OI"
lab var interest_3 "Enterprising 1.B.1.e OI"
lab var interest_4 "First Interest High-Point 1.B.1.g IH"
lab var interest_5 "Investigative 1.B.1.b OI"
lab var interest_6 "Realistic 1.B.1.a OI"
lab var interest_7 "Second Interest High-Point 1.B.1.h IH"
lab var interest_8 "Social 1.B.1.d OI"
lab var interest_9 "Third Interest High-Point 1.B.1.i IH"

save "${temp}/onet_interest00-22combined.dta", replace
}


*******************************************************************************
** Clean O*NET Knowledge data (2000-)
*******************************************************************************
{
import excel "${onet_data}/knowledge.xlsx", sheet("KNOWLEDGE") firstrow case(lower) clear

** reorder variables
order o_net_soc_code-scale_id ///
	 _2000_8  _2001_6  _2002_7  _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11 


** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** encode element_name to a numeric variable
gen element = element_name + " " + element_id + " " + scale_id
encode element, gen(knowledgename)


** combine different waves from the same year
foreach x of numlist 2000/2022 {
	
		egen onet_knowledge`x' = rowmedian(_`x'_*)
	}

** generate the knowledge variables for each soc occupation 
foreach x of numlist 2000(1)2022 {
		bys soc knowledgename: egen knowledge_`x' = mean(onet_knowledge`x')
}

** keep one copy for each soc occupation's knowledge
bys soc knowledgename: keep if _n == 1

** keep useful variables
keep soc knowledgename knowledge_2000-knowledge_2022

** reshape into a long soc*year*knowledge file
egen newid = concat(soc knowledgename), punct(-kn)
reshape long knowledge_, i(newid) j(year) 

** reshape into a wide soc*year file
drop newid
egen newid = concat(soc year), punct(-yr)
reshape wide knowledge_, i(newid) j(knowledgename) 
drop newid

** add labels to knowledge variables
lab var knowledge_1   	"Administration and Management 2.C.1.a IM"
lab var knowledge_2   	"Administration and Management 2.C.1.a LV"
lab var knowledge_3  	"Biology 2.C.4.d IM"
lab var knowledge_4  	"Biology 2.C.4.d LV"
lab var knowledge_5  	"Building and Construction 2.C.3.d IM"
lab var knowledge_6  	"Building and Construction 2.C.3.d LV"
lab var knowledge_7  	"Chemistry 2.C.4.c IM"
lab var knowledge_8  	"Chemistry 2.C.4.c LV"
lab var knowledge_9  	"Clerical 2.C.1.b IM"
lab var knowledge_10 	"Clerical 2.C.1.b LV"
lab var knowledge_11 	"Communications and Media 2.C.9.b IM"
lab var knowledge_12 	"Communications and Media 2.C.9.b LV"
lab var knowledge_13 	"Computers and Electronics 2.C.3.a IM"
lab var knowledge_14 	"Computers and Electronics 2.C.3.a LV"
lab var knowledge_15 	"Customer and Personal Service 2.C.1.e IM"
lab var knowledge_16 	"Customer and Personal Service 2.C.1.e LV"
lab var knowledge_17 	"Design 2.C.3.c IM"
lab var knowledge_18 	"Design 2.C.3.c LV"
lab var knowledge_19 	"Economics and Accounting 2.C.1.c IM"
lab var knowledge_20 	"Economics and Accounting 2.C.1.c LV"
lab var knowledge_21 	"Education and Training 2.C.6 IM"
lab var knowledge_22 	"Education and Training 2.C.6 LV"
lab var knowledge_23 	"Engineering and Technology 2.C.3.b IM"
lab var knowledge_24 	"Engineering and Technology 2.C.3.b LV"
lab var knowledge_25 	"English Language 2.C.7.a IM"
lab var knowledge_26 	"English Language 2.C.7.a LV"
lab var knowledge_27 	"Fine Arts 2.C.7.c IM"
lab var knowledge_28 	"Fine Arts 2.C.7.c LV"
lab var knowledge_29 	"Food Production 2.C.2.b IM"
lab var knowledge_30 	"Food Production 2.C.2.b LV"
lab var knowledge_31 	"Foreign Language 2.C.7.b IM"
lab var knowledge_32 	"Foreign Language 2.C.7.b LV"
lab var knowledge_33 	"Geography 2.C.4.g IM"
lab var knowledge_34 	"Geography 2.C.4.g LV"
lab var knowledge_35 	"History and Archeology 2.C.7.d IM"
lab var knowledge_36 	"History and Archeology 2.C.7.d LV"
lab var knowledge_37 	"Law and Government 2.C.8.b IM"
lab var knowledge_38 	"Law and Government 2.C.8.b LV"
lab var knowledge_39 	"Mathematics 2.C.4.a IM"
lab var knowledge_40 	"Mathematics 2.C.4.a LV"
lab var knowledge_41 	"Mechanical 2.C.3.e IM"
lab var knowledge_42 	"Mechanical 2.C.3.e LV"
lab var knowledge_43 	"Medicine and Dentistry 2.C.5.a IM"
lab var knowledge_44 	"Medicine and Dentistry 2.C.5.a LV"
lab var knowledge_45 	"Personnel and Human Resources 2.C.1.f IM"
lab var knowledge_46 	"Personnel and Human Resources 2.C.1.f LV"
lab var knowledge_47 	"Philosophy and Theology 2.C.7.e IM"
lab var knowledge_48 	"Philosophy and Theology 2.C.7.e LV"
lab var knowledge_49 	"Physics 2.C.4.b IM"
lab var knowledge_50 	"Physics 2.C.4.b LV"
lab var knowledge_51 	"Production and Processing 2.C.2.a IM"
lab var knowledge_52 	"Production and Processing 2.C.2.a LV"
lab var knowledge_53 	"Psychology 2.C.4.e IM"
lab var knowledge_54 	"Psychology 2.C.4.e LV"
lab var knowledge_55 	"Public Safety and Security 2.C.8.a IM"
lab var knowledge_56 	"Public Safety and Security 2.C.8.a LV"
lab var knowledge_57 	"Sales and Marketing 2.C.1.d IM"
lab var knowledge_58 	"Sales and Marketing 2.C.1.d LV"
lab var knowledge_59 	"Sociology and Anthropology 2.C.4.f IM"
lab var knowledge_60 	"Sociology and Anthropology 2.C.4.f LV"
lab var knowledge_61 	"Telecommunications 2.C.9.a IM"
lab var knowledge_62 	"Telecommunications 2.C.9.a LV"
lab var knowledge_63 	"Therapy and Counseling 2.C.5.b IM"
lab var knowledge_64 	"Therapy and Counseling 2.C.5.b LV"
lab var knowledge_65 	"Transportation 2.C.10 IM"
lab var knowledge_66 	"Transportation 2.C.10 LV"

save "${temp}/onet_knowledge00-22combined.dta", replace	 
}

*******************************************************************************
** Clean O*NET Work Activity data (2000-)
*******************************************************************************
{
import excel "${onet_data}/work_activities.xlsx", sheet("WORK_ACTIVITIES") firstrow case(lower) clear

** reorder variables
order o_net_soc_code-scale_id ///
	 _2000_8  _2001_6  _2002_7  _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11 

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** encode element_name to a numeric variable
gen element = element_name + " " + element_id + " " + scale_id
encode element, gen(wkactivityname)


** combine different waves from the same year
foreach x of numlist 2000/2022 {
	
		egen onet_wkactivity`x' = rowmedian(_`x'_*)
	}

** generate the work activity variables for each soc occupation 
foreach x of numlist 2000(1)2022 {
		bys soc wkactivityname: egen wkactivity_`x' = mean(onet_wkactivity`x')
}

** keep one copy for each soc occupation's work activity 
bys soc wkactivityname: keep if _n == 1

** keep useful variables
keep soc wkactivityname wkactivity_2000-wkactivity_2022 

** reshape into a long soc*year*wk activity file
egen newid = concat(soc wkactivityname), punct(-wk)
reshape long wkactivity_, i(newid) j(year) 

** reshape into a wide soc*year file
drop newid
egen newid = concat(soc year), punct(-yr)
reshape wide wkactivity_, i(newid) j(wkactivityname) 
drop newid

** add labels to work activity variables
lab var wkactivity_1   	                                                  "Analyzing Data or Information 4.A.2.a.4 IM"
lab var wkactivity_2   	                                                  "Analyzing Data or Information 4.A.2.a.4 LV"
lab var wkactivity_3   	                                                "Assisting and Caring for Others 4.A.4.a.5 IM"
lab var wkactivity_4   	                                                "Assisting and Caring for Others 4.A.4.a.5 LV"
lab var wkactivity_5   	                                                 "Coaching and Developing Others 4.A.4.b.5 IM"
lab var wkactivity_6   	                                                 "Coaching and Developing Others 4.A.4.b.5 LV"
lab var wkactivity_7   	                                "Communicating with Persons Outside Organization 4.A.4.a.3 IM"
lab var wkactivity_8   	                                "Communicating with Persons Outside Organization 4.A.4.a.3 LV"
lab var wkactivity_9   	                         "Communicating with Supervisors, Peers, or Subordinates 4.A.4.a.2 IM"
lab var wkactivity_10  	                         "Communicating with Supervisors, Peers, or Subordinates 4.A.4.a.2 LV"
lab var wkactivity_11  	                                             "Controlling Machines and Processes 4.A.3.a.3 IM"
lab var wkactivity_12  	                                             "Controlling Machines and Processes 4.A.3.a.3 LV"
lab var wkactivity_13  	                                 "Coordinating the Work and Activities of Others 4.A.4.b.1 IM"
lab var wkactivity_14  	                                 "Coordinating the Work and Activities of Others 4.A.4.b.1 LV"
lab var wkactivity_15  	                                           "Developing Objectives and Strategies 4.A.2.b.4 IM"
lab var wkactivity_16  	                                           "Developing Objectives and Strategies 4.A.2.b.4 LV"
lab var wkactivity_17  	                                                  "Developing and Building Teams 4.A.4.b.2 IM"
lab var wkactivity_18  	                                                  "Developing and Building Teams 4.A.4.b.2 LV"
lab var wkactivity_19  	                                              "Documenting/Recording Information 4.A.3.b.6 IM"
lab var wkactivity_20  	                                              "Documenting/Recording Information 4.A.3.b.6 LV"
lab var wkactivity_21  	   "Drafting, Laying Out, and Specifying Technical Devices, Parts, and Equipment 4.A.3.b.2 IM"
lab var wkactivity_22  	   "Drafting, Laying Out, and Specifying Technical Devices, Parts, and Equipment 4.A.3.b.2 LV"
lab var wkactivity_23  	                       "Establishing and Maintaining Interpersonal Relationships 4.A.4.a.4 IM"
lab var wkactivity_24  	                       "Establishing and Maintaining Interpersonal Relationships 4.A.4.a.4 LV"
lab var wkactivity_25  	"Estimating the Quantifiable Characteristics of Products, Events, or Information 4.A.1.b.3 IM"
lab var wkactivity_26  	"Estimating the Quantifiable Characteristics of Products, Events, or Information 4.A.1.b.3 LV"
lab var wkactivity_27  	                  "Evaluating Information to Determine Compliance with Standards 4.A.2.a.3 IM"
lab var wkactivity_28  	                  "Evaluating Information to Determine Compliance with Standards 4.A.2.a.3 LV"
lab var wkactivity_29  	                                                            "Getting Information 4.A.1.a.1 IM"
lab var wkactivity_30  	                                                            "Getting Information 4.A.1.a.1 LV"
lab var wkactivity_31  	                                "Guiding, Directing, and Motivating Subordinates 4.A.4.b.4 IM"
lab var wkactivity_32  	                                "Guiding, Directing, and Motivating Subordinates 4.A.4.b.4 LV"
lab var wkactivity_33  	                                                    "Handling and Moving Objects 4.A.3.a.2 IM"
lab var wkactivity_34  	                                                    "Handling and Moving Objects 4.A.3.a.2 LV"
lab var wkactivity_35  	                                       "Identifying Objects, Actions, and Events 4.A.1.b.1 IM"
lab var wkactivity_36  	                                       "Identifying Objects, Actions, and Events 4.A.1.b.1 LV"
lab var wkactivity_37  	                                  "Inspecting Equipment, Structures, or Material 4.A.1.b.2 IM"
lab var wkactivity_38  	                                  "Inspecting Equipment, Structures, or Material 4.A.1.b.2 LV"
lab var wkactivity_39  	                                                     "Interacting With Computers 4.A.3.b.1 IM"
lab var wkactivity_40  	                                                     "Interacting With Computers 4.A.3.b.1 LV"
lab var wkactivity_41  	                             "Interpreting the Meaning of Information for Others 4.A.4.a.1 IM"
lab var wkactivity_42  	                             "Interpreting the Meaning of Information for Others 4.A.4.a.1 LV"
lab var wkactivity_43  	                           "Judging the Qualities of Things, Services, or People 4.A.2.a.1 IM"
lab var wkactivity_44  	                           "Judging the Qualities of Things, Services, or People 4.A.2.a.1 LV"
lab var wkactivity_45  	                                          "Making Decisions and Solving Problems 4.A.2.b.1 IM"
lab var wkactivity_46  	                                          "Making Decisions and Solving Problems 4.A.2.b.1 LV"
lab var wkactivity_47  	                                  "Monitor Processes, Materials, or Surroundings 4.A.1.a.2 IM"
lab var wkactivity_48  	                                  "Monitor Processes, Materials, or Surroundings 4.A.1.a.2 LV"
lab var wkactivity_49  	                                           "Monitoring and Controlling Resources 4.A.4.c.3 IM"
lab var wkactivity_50  	                                           "Monitoring and Controlling Resources 4.A.4.c.3 LV"
lab var wkactivity_51  	                           "Operating Vehicles, Mechanized Devices, or Equipment 4.A.3.a.4 IM"
lab var wkactivity_52  	                           "Operating Vehicles, Mechanized Devices, or Equipment 4.A.3.a.4 LV"
lab var wkactivity_53  	                                    "Organizing, Planning, and Prioritizing Work 4.A.2.b.6 IM"
lab var wkactivity_54  	                                    "Organizing, Planning, and Prioritizing Work 4.A.2.b.6 LV"
lab var wkactivity_55  	                                           "Performing Administrative Activities 4.A.4.c.1 IM"
lab var wkactivity_56  	                                           "Performing Administrative Activities 4.A.4.c.1 LV"
lab var wkactivity_57  	                                         "Performing General Physical Activities 4.A.3.a.1 IM"
lab var wkactivity_58  	                                         "Performing General Physical Activities 4.A.3.a.1 LV"
lab var wkactivity_59  	                             "Performing for or Working Directly with the Public 4.A.4.a.8 IM"
lab var wkactivity_60  	                             "Performing for or Working Directly with the Public 4.A.4.a.8 LV"
lab var wkactivity_61  	                                                         "Processing Information 4.A.2.a.2 IM"
lab var wkactivity_62  	                                                         "Processing Information 4.A.2.a.2 LV"
lab var wkactivity_63  	                                      "Provide Consultation and Advice to Others 4.A.4.b.6 IM"
lab var wkactivity_64  	                                      "Provide Consultation and Advice to Others 4.A.4.b.6 LV"
lab var wkactivity_65  	                                 "Repairing and Maintaining Electronic Equipment 4.A.3.b.5 IM"
lab var wkactivity_66  	                                 "Repairing and Maintaining Electronic Equipment 4.A.3.b.5 LV"
lab var wkactivity_67  	                                 "Repairing and Maintaining Mechanical Equipment 4.A.3.b.4 IM"
lab var wkactivity_68  	                                 "Repairing and Maintaining Mechanical Equipment 4.A.3.b.4 LV"
lab var wkactivity_69  	                                "Resolving Conflicts and Negotiating with Others 4.A.4.a.7 IM"
lab var wkactivity_70  	                                "Resolving Conflicts and Negotiating with Others 4.A.4.a.7 LV"
lab var wkactivity_71  	                                                 "Scheduling Work and Activities 4.A.2.b.5 IM"
lab var wkactivity_72  	                                                 "Scheduling Work and Activities 4.A.2.b.5 LV"
lab var wkactivity_73  	                                                  "Selling or Influencing Others 4.A.4.a.6 IM"
lab var wkactivity_74  	                                                  "Selling or Influencing Others 4.A.4.a.6 LV"
lab var wkactivity_75  	                                                  "Staffing Organizational Units 4.A.4.c.2 IM"
lab var wkactivity_76  	                                                  "Staffing Organizational Units 4.A.4.c.2 LV"
lab var wkactivity_77  	                                                            "Thinking Creatively 4.A.2.b.2 IM"
lab var wkactivity_78  	                                                            "Thinking Creatively 4.A.2.b.2 LV"
lab var wkactivity_79  	                                                   "Training and Teaching Others 4.A.4.b.3 IM"
lab var wkactivity_80  	                                                   "Training and Teaching Others 4.A.4.b.3 LV"
lab var wkactivity_81  	                                          "Updating and Using Relevant Knowledge 4.A.2.b.3 IM"
lab var wkactivity_82  	                                          "Updating and Using Relevant Knowledge 4.A.2.b.3 LV"
	

save "${temp}/onet_work-activity00-22combined.dta", replace	 
}

*******************************************************************************
** Clean O*NET Work Styles data
*******************************************************************************
{
import excel "${onet_data}/work_styles.xlsx", sheet("WORK_STYLES") firstrow case(lower) clear

** reorder variables
order o_net_soc_code-scale_id ///
	 _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11 

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** encode element_name to a numeric variable
gen element = element_name + " " + element_id + " " + scale_id
encode element, gen(wkstylename)


** combine different waves from the same year
foreach x of numlist 2003/2022 {
	
		egen onet_wkstyle`x' = rowmedian(_`x'_*)
	}

** generate the work styles variables for each soc occupation 
foreach x of numlist 2003(1)2022 {
		bys soc wkstylename: egen wkstyle_`x' = mean(onet_wkstyle`x')
}

** keep one copy for each soc occupation's work styles
bys soc wkstylename: keep if _n == 1

** keep useful variables
keep soc wkstylename wkstyle_2003-wkstyle_2022

** reshape into a long soc*year*work styles file
egen newid = concat(soc wkstylename), punct(-st)
reshape long wkstyle_, i(newid) j(year) 

** reshape into a wide soc*year file
drop newid
egen newid = concat(soc year), punct(-yr)
reshape wide wkstyle_, i(newid) j(wkstylename) 
drop newid

** add labels to work style variables
lab var wkstyle_1   "Achievement/Effort 1.C.1.a IM"                  
lab var wkstyle_2   "Adaptability/Flexibility 1.C.4.c IM" 	                    
lab var wkstyle_3   "Analytical Thinking 1.C.7.b IM"                     
lab var wkstyle_4   "Attention to Detail 1.C.5.b IM" 	   	                    
lab var wkstyle_5   "Concern for Others 1.C.3.b IM"    	                    
lab var wkstyle_6   "Cooperation 1.C.3.a IM"                      
lab var wkstyle_7   "Dependability 1.C.5.a IM"  
lab var wkstyle_8   "Independence 1.C.6 IM" 
lab var wkstyle_9   "Initiative 1.C.1.c IM" 
lab var wkstyle_10  "Innovation 1.C.7.a IM" 
lab var wkstyle_11  "Integrity 1.C.5.c IM"    
lab var wkstyle_12  "Leadership 1.C.2.b IM"
lab var wkstyle_13  "Persistence 1.C.1.b IM" 
lab var wkstyle_14  "Self Control 1.C.4.a IM"
lab var wkstyle_15  "Social Orientation 1.C.3.c IM"   
lab var wkstyle_16  "Stress Tolerance 1.C.4.b IM" 			                  	                    

save "${temp}/onet_work-styles03-22combined.dta", replace	
}

*******************************************************************************
** Clean O*NET Work Values data （2000-）
*******************************************************************************
{
import excel "${onet_data}/work_values.xlsx", sheet("WORK_VALUES") firstrow case(lower) clear

** reorder variables
order o_net_soc_code-scale_id ///
	 _2000_8  _2001_6  _2002_7  _2003_4  _2003_11 _2004_7  _2004_12 	///
	 _2005_6  _2005_12 _2006_6  _2006_12 _2007_7 _2008_7	///
	 _2009_7  _2010_7  _2011_2  _2011_7	 _2012_7 _2013_7	///
	 _2014_3  _2014_7  _2015_8  _2015_10 _2016_2 _2016_4    ///
	 _2016_8  _2016_11 _2017_2	_2017_5	 _2017_8 _2017_10   ///
	 _2018_2  _2018_5  _2018_8	_2018_11 _2019_2 _2019_5	///
	 _2019_8  _2019_11 _2020_2  _2020_5	 _2020_8 _2020_11   ///
	 _2021_2  _2021_5  _2021_8  _2021_11 _2022_2 _2022_5	///
	 _2022_8  _2022_11 

** generate soc code
gen soc = substr(o_net_soc_code,1,7)

** encode element_name to a numeric variable
gen element = element_name + " " + element_id + " " + scale_id
encode element, gen(wkvaluename)


** combine different waves from the same year
foreach x of numlist 2000/2022 {
	
		egen onet_wkvalue`x' = rowmedian(_`x'_*)
	}

** generate the knowledge variables for each soc occupation 
foreach x of numlist 2000(1)2022 {
		bys soc wkvaluename: egen wkvalue_`x' = mean(onet_wkvalue`x')
}

** keep one copy for each soc occupation's work values
bys soc wkvaluename: keep if _n == 1

** keep useful variables
keep soc wkvaluename wkvalue_2000-wkvalue_2022

** reshape into a long soc*year*wkvalue file
egen newid = concat(soc wkvaluename), punct(-wkv)
reshape long wkvalue_, i(newid) j(year) 

** reshape into a wide soc*year file
drop newid
egen newid = concat(soc year), punct(-yr)
reshape wide wkvalue_, i(newid) j(wkvaluename) 
drop newid

** add labels to work value variables
lab var wkvalue_1 		           "Ability Utilization 1.B.2.a.1 EN"
lab var wkvalue_2 		                      "Achievement 1.B.2.a EN"
lab var wkvalue_3 		                      "Achievement 1.B.2.a EX"
lab var wkvalue_4 		                    "Achievement 1.B.2.a.2 EN"
lab var wkvalue_5 		                       "Activity 1.B.2.b.1 EN"
lab var wkvalue_6 		                    "Advancement 1.B.2.c.1 EN"
lab var wkvalue_7 		                      "Authority 1.B.2.c.3 EN"
lab var wkvalue_8 		                       "Autonomy 1.B.2.f.3 EN"
lab var wkvalue_9 		                     "Co-workers 1.B.2.d.1 EN"
lab var wkvalue_10		  "Company Policies and Practices 1.B.2.e.1 EN"
lab var wkvalue_11		                   "Compensation 1.B.2.b.4 EN"
lab var wkvalue_12		                     "Creativity 1.B.2.f.1 EN"
lab var wkvalue_13		      "First Work Value High-Point 1.B.2.g VH"
lab var wkvalue_14		                   "Independence 1.B.2.b.2 EN"
lab var wkvalue_15		                     "Independence 1.B.2.f EN"
lab var wkvalue_16		                     "Independence 1.B.2.f EX"
lab var wkvalue_17		                   "Moral Values 1.B.2.d.3 EN"
lab var wkvalue_18		                      "Recognition 1.B.2.c EN"
lab var wkvalue_19		                      "Recognition 1.B.2.c EX"
lab var wkvalue_20		                    "Recognition 1.B.2.c.2 EN"
lab var wkvalue_21		                    "Relationships 1.B.2.d EN"
lab var wkvalue_22		                    "Relationships 1.B.2.d EX"
lab var wkvalue_23		                 "Responsibility 1.B.2.f.2 EN"
lab var wkvalue_24		     "Second Work Value High-Point 1.B.2.h VH"
lab var wkvalue_25		                       "Security 1.B.2.b.5 EN"
lab var wkvalue_26		                 "Social Service 1.B.2.d.2 EN"
lab var wkvalue_27		                  "Social Status 1.B.2.c.4 EN"
lab var wkvalue_28		   "Supervision, Human Relations 1.B.2.e.2 EN"
lab var wkvalue_29		         "Supervision, Technical 1.B.2.e.3 EN"
lab var wkvalue_30		                          "Support 1.B.2.e EN"
lab var wkvalue_31		                          "Support 1.B.2.e EX"
lab var wkvalue_32		      "Third Work Value High-Point 1.B.2.i VH"
lab var wkvalue_33		                        "Variety 1.B.2.b.3 EN"
lab var wkvalue_34		               "Working Conditions 1.B.2.b EN"
lab var wkvalue_35		               "Working Conditions 1.B.2.b EX"
lab var wkvalue_36		             "Working Conditions 1.B.2.b.6 EN"

save "${temp}/onet_work-values00-22combined.dta", replace	
}
